use std::ptr::null;

fn main() {
    // let v1: Vec<People> = vec![
    //     People {
    //         age: 18,
    //         name: "yiwyn".to_string(),
    //     }
    // ];
    //
    // let mut v1_iter = v1.iter();
    //
    // let v2: Vec<_> = v1_iter.filter(|p| p.age == 18).collect();
    //
    // for x in v2 {
    //     println!("{}", x.name)
    // }

    let mut c: Counter = Counter::new();

    let a = c.next().unwrap();

    println!("{:?}", a)
}


struct People {
    age: i32,
    name: String,
}

struct Counter {
    count: i32,
}

impl Counter {
    fn new() -> Counter {
        Counter {
            count: 0
        }
    }
}

impl Iterator for Counter {
    type Item = i32;
    fn next(&mut self) -> Option<Self::Item> {
        self.count += 1;
        if self.count < 6 {
            Some(self.count)
        } else {
            None
        }
    }
}
